
package com.zsrt.Io;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.Reader;
import java.io.Writer;

public class ReadIo {

	public static void main(String[] args)throws Exception {
		
		//存放问题的文件
		File file = new File("src/com/zsrt/Io/Ask.txt");
		Reader reader = new FileReader(file);
		BufferedReader br = new BufferedReader(reader);
		
		//存放结果的文件
		File file1 =new File("src/com/zsrt/Io/Answer.txt");
		Writer writer = new FileWriter(file1);
		BufferedWriter bw = new BufferedWriter(writer);
		//读取文件内容
		String line = null;
		while((line = br.readLine())!=null){
			//得到文件的一行字符串  去掉= 号
			String sub = line.substring(0, line.length()-1);
			//System.out.println(sub);
			
			//保留运算结果
			int result = 0;
			//保存最后结果的字符串
			String str=null;
			//如果字符串包含+ 号 进行加法运算  
			if(sub.contains("+")){
				//截取运算符前和后的数字
				String[] splits = sub.split("\\+");
				int preNum = Integer.parseInt(splits[0]);
				int afterNum = Integer.parseInt(splits[1]);
				
				result = preNum+afterNum;
				str = line+result;
				//System.out.println(str);
			}else if(line.contains("-")){
				//截取运算符前和后的数字
				String[] splits = sub.split("\\-");
				int preNum = Integer.parseInt(splits[0]);
				int afterNum = Integer.parseInt(splits[1]);
				
				result = preNum-afterNum;
				str = line+result;
				//System.out.println(str);
			}else if(line.contains("*")){
				//截取运算符前和后的数字
				String[] splits = sub.split("\\*");
				int preNum = Integer.parseInt(splits[0]);
				int afterNum = Integer.parseInt(splits[1]);
				
				result = preNum*afterNum;
				str = line+result;
				//System.out.println(str);
			}else{
				//截取运算符前和后的数字
				String[] splits = sub.split("\\/");
				int preNum = Integer.parseInt(splits[0]);
				int afterNum = Integer.parseInt(splits[1]);
				
				result = preNum/afterNum;
				str = line+result;
				//System.out.println(str);
			}
			
			//存放结果
			bw.write(str);
			//换行
			bw.newLine();
		}
		
		bw.close();
		writer.close();
		br.close();
		reader.close();
	}
}
